package com.lagou.edu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class LoginController {

    @RequestMapping("/login")
    @ResponseBody
    public String login(HttpServletRequest req, HttpServletResponse resp, String userName, String password) throws Exception {
        ModelAndView view = new ModelAndView();
        if ("admin".equals(userName) && "admin".equals(password)) {
            req.getSession().setAttribute("loginSession",userName);
            return "ok";
        }
        return  "err";
    }

}
